<?php

namespace App\Models;

use Database\Factories\roleFactory;
use Dcat\Admin\Traits\HasDateTimeFormatter;
use Eloquent;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Carbon;

/**
 * App\Models\role
 *
 * @property int $id
 * @property string $name
 * @property Carbon|null $created_at
 * @property Carbon|null $updated_at
 * @property-read Collection|\App\Models\User[] $user
 * @property-read int|null $user_count
 * @method static roleFactory factory(...$parameters)
 * @method static Builder|role newModelQuery()
 * @method static Builder|role newQuery()
 * @method static Builder|role query()
 * @method static Builder|role whereCreatedAt($value)
 * @method static Builder|role whereId($value)
 * @method static Builder|role whereName($value)
 * @method static Builder|role whereUpdatedAt($value)
 * @mixin Eloquent
 */
class role extends Model
{
    use HasFactory, HasDateTimeFormatter;

    /**
     *  角色所拥有的用户
     */
    public function user()
    {
        return $this->belongsToMany(User::class);
    }
}
